﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HeresyManager.Careers;

namespace HeresyManager.HomeWorlds
{
    [Serializable]
    class ForgeWorld : HomeWorld
    {
        private Trait[] traits;
        private Skill[] skills;
        public override string Name
        {
            get { return "Forge World"; }
        }


        public override IEnumerator<Comunication.Comunicator> Acire(Character c)
        {
            skills = new Skill[] { new Skills.CommonLores.CommonLoreTech(Skill.SkillLevel.Basic), new Skills.CommonLores.CommonLoreMachineCult(Skill.SkillLevel.Basic) };
            traits = new Trait[] { new Traits.FitForPurpose(), new Traits.StrangerToTheCult(), new Traits.CredoOmnissiah() };

            var e = base.Acire(c);
            while (e.MoveNext())
                yield return e.Current;

            foreach (var s in traits)
            {
                e = c.AddTrait(s, this);
                while (e.MoveNext())
                    yield return e.Current;
            }
            foreach (var s in skills)
            {
                e = c.AddSkill(s, this);
                while (e.MoveNext())
                    yield return e.Current;
            }
        }

        public override void DeAcire(Character c)
        {
            base.DeAcire(c);
            foreach (var s in traits)
                c.RemoveTrait(s, this);
            foreach (var s in skills)
                c.RemoveSkill(s, this);
        }

        #region CharackteristicDices

        public override IDice WeaponSkillDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(15)); }
        }

        public override IDice BallisitcSkillDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice StrengthDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice ToughnessDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice AgillityDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice IntelligenceDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(25)); }
        }

        public override IDice PerceptionDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice WillpowerDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }

        public override IDice FellowshipDice
        {
            get { return new DiceCollection(new DiceMultiplier(new Dice(10), 2), new DiceNumber(20)); }
        }
        #endregion

        public override IDice WoundsDice
        {
            get { return new DiceCollection(new Dice(5), new DiceNumber(7)); }
        }

        public override IDice FateDice
        {
            get { return new FunctionDice<int>(new Dice(10), i => { if (i <= 5) return 1; if (i <= 9)return 2; else return 3; }); }
        }

        #region Apereance
        public override Build[] Builds
        {
            get
            {
                return new Build[] {                                                                                                   
                new Build() { Descripton = "Slender", Gender = Gender.Male, MinRole = 1, MaxRole = 20, Size = 1.75f, Weight = 65 } ,
                new Build() { Descripton = "Svelte", Gender = Gender.Male, MinRole = 21, MaxRole = 50, Size = 1.85f, Weight = 70 } ,
                new Build() { Descripton = "Fit", Gender = Gender.Male, MinRole = 51, MaxRole = 80, Size = 1.75f, Weight = 70 } ,
                new Build() { Descripton = "Well-bult", Gender = Gender.Male, MinRole = 81, MaxRole = 90, Size = 1.90f, Weight = 90 } ,
                new Build() { Descripton = "Stocky", Gender = Gender.Male, MinRole = 91, MaxRole = 100, Size = 1.80f, Weight = 100 } ,
                new Build() { Descripton = "Slender", Gender = Gender.Female, MinRole = 1, MaxRole = 20, Size = 1.65f, Weight = 60 } ,
                new Build() { Descripton = "Svelte", Gender = Gender.Female, MinRole = 21, MaxRole = 50, Size = 1.75f, Weight = 65 } ,
                new Build() { Descripton = "Fit", Gender = Gender.Female, MinRole = 51, MaxRole = 80, Size = 1.65f, Weight = 60 } ,
                new Build() { Descripton = "Well-bult", Gender = Gender.Female, MinRole = 81, MaxRole = 90, Size = 1.80f, Weight = 80 } ,
                new Build() { Descripton = "Stocky", Gender = Gender.Female, MinRole = 91, MaxRole = 100, Size = 1.70f, Weight = 90 } 
            };
            }
        }

        public override Age[] Ages
        {
            get
            {
                return new Age[] {
                    new Age(){ Description="Stripling", Dice = new DiceCollection(new DiceNumber(20) ,new Dice(10)), MinRole=1, MaxRole=50},
                    new Age(){ Description="Mature", Dice = new DiceCollection(new DiceNumber(30) ,new Dice(10)), MinRole=51, MaxRole=80},
                    new Age(){ Description="Veteran", Dice = new DiceCollection(new DiceNumber(40) ,new Dice(10)), MinRole=81, MaxRole=100}
            };
            }
        }

        public override Color[] SkinColors
        {
            get
            {
                return new Color[]{
                    new Color(){ Name="Dark", MinRole = 1, MaxRole=30},
                    new Color(){ Name="Tan", MinRole = 31, MaxRole=50},
                    new Color(){ Name="Fair", MinRole = 51, MaxRole=70},
                    new Color(){ Name="Ruddy", MinRole = 71, MaxRole=90},
                    new Color(){ Name="Dyed (any)", MinRole = 91, MaxRole=100}            
                };
            }
        }

        public override Color[] HairColors
        {
            get
            {
                return new Color[]{
                    new Color(){ Name="Dyed (any)", MinRole = 1, MaxRole=30},
                    new Color(){ Name="Blond", MinRole = 31, MaxRole=50},
                    new Color(){ Name="Brown", MinRole = 51, MaxRole=70},
                    new Color(){ Name="Black", MinRole = 71, MaxRole=90},
                    new Color(){ Name="Grey", MinRole = 91, MaxRole=100}            
                };
            }
        }

        public override Color[] EyeColors
        {
            get
            {
                return new Color[]{
                    new Color(){ Name="Blue", MinRole = 1, MaxRole=30},
                    new Color(){ Name="Grey", MinRole = 31, MaxRole=50},
                    new Color(){ Name="Brown", MinRole = 51, MaxRole=70},
                    new Color(){ Name="Green", MinRole = 71, MaxRole=90},
                    new Color(){ Name="LLenses (any)", MinRole = 91, MaxRole=100}            
                };
            }
        }

        public override Quirk[] Quirks
        {
            get
            {
                return new Quirk[]{
                    new Quirk(){ Description="Missing Digit", MinRole=1, MaxRole=6},
                    new Quirk(){ Description="Aquiline Nose", MinRole=7, MaxRole=13},
                    new Quirk(){ Description="Warts", MinRole=14, MaxRole=20},
                    new Quirk(){ Description="Suelling Scar", MinRole=21, MaxRole=27},
                    new Quirk(){ Description="Pirced Nose", MinRole=28, MaxRole=34},
                    new Quirk(){ Description="Nervous Tic", MinRole=35, MaxRole=41},
                    new Quirk(){ Description="Aquila Tattoo", MinRole=42, MaxRole=48},
                    new Quirk(){ Description="Faint Smell", MinRole=49, MaxRole=55},
                    new Quirk(){ Description="Pox Marks", MinRole=56, MaxRole=61},
                    new Quirk(){ Description="Devotional Scar", MinRole=62, MaxRole=68},
                    new Quirk(){ Description="Electoo", MinRole=69, MaxRole=75},
                    new Quirk(){ Description="Quivering Fingers", MinRole=76, MaxRole=82},
                    new Quirk(){ Description="Pirced Ears", MinRole=83, MaxRole=87},
                    new Quirk(){ Description="Sinister Boil", MinRole=88, MaxRole=88},
                    new Quirk(){ Description="Make-up", MinRole=89, MaxRole=95},
                    new Quirk(){ Description="Slouched Gait", MinRole=96, MaxRole=100},
            };
            }
        }

        public override string OriginDescription
        {
            get { return "Birth Planet"; }
        }

        public override Origin[] Origins
        {
            get
            {
                return new Origin[]{
                     new Origin(){ Description="Greater Forge World", MinRole= 1, MaxRole=30 },
                     new Origin(){ Description="Minor Jorge World", MinRole= 31, MaxRole=47 },
                     new Origin(){ Description="Orbital", MinRole= 48, MaxRole=61 },
                     new Origin(){ Description="Demesne", MinRole= 62, MaxRole=74 },
                     new Origin(){ Description="Research Outpost", MinRole= 75, MaxRole=89 },
                     new Origin(){ Description="Explorator Fleet", MinRole= 90, MaxRole=100 },
            };
            }
        }
        #endregion



        public override Tuple<Type, int, int>[] AccirableCareers
        {
            get { return new Tuple<Type, int, int>[] { new Tuple<Type, int, int>(typeof(Adept), 1, 25), new Tuple<Type, int, int>(typeof(Assassin), 26, 35), new Tuple<Type, int, int>(typeof(Guardsman), 36, 60), new Tuple<Type, int, int>(typeof(Scum), 61, 70), new Tuple<Type, int, int>(typeof(TechPriest), 71, 100) }; }
        }

        public override int MinRole
        {
            get { return 66; }
        }

        public override int MaxRole
        {
            get { return 75; }
        }
    }
}
